<template>
	<div class="main" :class="theme" id="mainWrapper" @drop="onDropHandler">
		<title-bar :componentProps="{ windowId: 'main' }" :class="{ 'titlebar--error': errorAlert }" v-if="uiReady"/>

		 
		<login v-if="uiReady && !isLogin" @loginSuccess="loginSuccess"></login>
		<activity v-if="uiReady && isLogin" v-show="isActivity" @begin_live="begin_live" @end_live="end_live" @loginOut="loginOut" ref="activity"></activity>

		<div class="main-contents" v-if="uiReady && isLogin && !isActivity" :class="{ 'main-contents--right': renderDock && leftDock && hasLiveDock, 'main-contents--left': renderDock && !leftDock && hasLiveDock,'main-contents--onboarding': page === 'Onboarding',}">
			<side-nav v-if="page !== 'Onboarding' && !showLoadingSpinner" :locked="applicationLoading" class="sidenav"/>
			<div class="live-dock-wrapper" v-if="renderDock && leftDock">
				<live-dock :onLeft="true" />
				<resize-bar
					v-if="!isDockCollapsed"
					class="live-dock-resize-bar live-dock-resize-bar--left"
					position="right"
					@resizestart="onResizeStartHandler"
					@resizestop="onResizeStopHandler"
					:max="maxDockWidth"
					:min="minDockWidth"
					:value="liveDockSize"/>
			</div>

			<div class="main-middle" :class="mainResponsiveClasses" ref="mainMiddle">
				<resize-observer @notify="handleResize" />
				<component
				class="main-page-container"
				v-if="!showLoadingSpinner"
				:is="page"
				:params="params"
				:component-props="{ params }"
				@totalWidth="width => handleEditorWidth(width)"
				style="grid-row: 1 / span 1"
				/>
				<studio-footer v-if="!applicationLoading && page !== 'Onboarding'" />
			</div>

			<div class="live-dock-wrapper" v-if="renderDock && !leftDock">
				<resize-bar
				v-if="!isDockCollapsed"
				class="live-dock-resize-bar"
				position="left"
				@resizestart="onResizeStartHandler"
				@resizestop="onResizeStopHandler"
				:max="maxDockWidth"
				:min="minDockWidth"
				:value="liveDockSize"
				:reverse="true"
				/>
				<live-dock class="live-dock" />
			</div>
		</div>
		<ModalWrapper :renderFn="modalOptions.renderFn" />
		<transition name="loader">
			<div
				class="main-loading"
				:class="{ 'initial-loading': !uiReady }"
				
				v-if="!uiReady || showLoadingSpinner">
				<custom-loader></custom-loader>
			</div>
		</transition>


		<div class="back_div" @click="end_live" v-if="uiReady && isLogin && !isActivity">
			<span>返回</span>
		</div>
	</div>
</template>

<script lang="ts" src="./Main.vue.ts"></script>

<style lang="less">
.main-middle--compact {
  .performance-metric-icon {
    height: 12px;
  }

  .performance-metric {
    font-size: 12px;
  }
}
</style>

<style lang="less" scoped>
@import '../../styles/index';

.sidenav {
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-grow: 1;
}
.login_div{
	width:100%;
	min-height: 100%;
	height: 100%;
	background:#fff
}
.main {
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
}

.main-contents {
  display: grid;
  grid-template-columns: auto 1fr;
  flex-grow: 1;
  height: 100%;
}

.main-contents--right {
  grid-template-columns: auto auto 1fr;
}

.main-contents--left {
  grid-template-columns: auto 1fr auto;
}

.main-contents--onboarding {
  grid-template-columns: 1fr;

  .main-middle {
    grid-template-rows: 1fr;
  }
}

.main-middle {
  flex-grow: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 48px;
  position: relative;
  height: 100%;
}

.titlebar--error {
  background: var(--warning) !important;

  /deep/ div,
  /deep/ .titlebar-action {
    color: var(--white) !important;
  }
}

.main-page-container {
  /* Page always takes up remaining space */
  flex-grow: 1;
  display: flex;
  position: relative;
}

.main-loading {
  position: absolute;
  top: 30px;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999999;
  background-color: var(--background);
  -webkit-app-region: drag;

  // Loader component is a fixed element that obscures the top bar
  /deep/ .s-loader__bg {
    top: 30px;
  }
}

.initial-loading {
  top: 0px !important;
}

.loader-enter-active,
.loader-leave-active {
  transition: opacity 0.5s ease-out;
}

.loader-enter,
.loader-leave-to {
  opacity: 0;
}

.live-dock {
  height: 100%;
}

.live-dock-wrapper {
  position: relative;
}

.live-dock-resize-bar {
  position: absolute;
  height: calc(100% - 20px);
  bottom: 0;
}

.live-dock-resize-bar--left {
  right: 0;
}

/deep/ .creator-sites-container .s-loader {
  .s-loader__bg {
    position: unset;
    z-index: unset;
  }
}

.login_code{
	width:100%;
	display:flex;
	align-items: center;
    justify-content: flex-start;
}
.lm_left {
    flex: 1;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #F3D083 0%, #F0D08B 100%);

}

.lm_right {
    flex: 1;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lmr_div {
    width: 480px;
}

.lmrd_action {
    display: flex;
    align-items: center;
    justify-content: flex-start;

}

.lmrda_div {
    font-size: 24px;
    color: #333333;
    line-height: 31px;
    letter-spacing: 3px;
    line-height: 31px;
    cursor: pointer;
}

.lmrda_div:last-child {
    margin-left: 40px;
}

.selectlmrda {
    font-size: 32px;
    color: #1670FF;
    font-weight: bold;
    letter-spacing: 4px;
    line-height: 42px;
}

.lmrd_input {
    width: 400px;
    display: inline-block;
    margin-top: 64px;
}

.lmrdi_txt {
    font-size: 18px;
    color: #666666;
    line-height: 24px;
}

.lmrdi_input {
    width: 100%;
    height: 48px;
    margin-top: 8px;
    border: 1px solid #D5D7DF;
    border-radius: 4px;
}

.lmrdi_input input {
    border: 0px;
    outline: none;
    padding-left: 16px;
    font-size: 18px;
    box-sizing: border-box;
    width: 100%;
    height: 48px;
}

.lmrd_yzm {
    width: 400px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    margin-top: 40px;
}

.lmrdy_left {
    flex: 1;
    margin-right: 20px;
}

.lmrdy_right {
    width: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.lmrdy_right img {
    width: 100%;
    height: 80px;
}

.lmrdy_right span {
    font-size: 18px;
    color: #6FAB69;
    line-height: 24px;
    margin-top: 8px;
}

.btnlist {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 76px;
}

.btn_div {
    width: 120px;
    height: 56px;
    background: #1670FF;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #FFFFFF;
    cursor: pointer;
}

.loginClass {
    height: 420px;
    width: 100%;
}
.qrcode_img {
    width: 100%;
    display: flex;
    align-items: center;
    /* justify-content: center; */
    margin-top: 30px;
}
.qrcode_desc{
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 18px;
    line-height: 24px;
    margin-top: 40px;
    cursor: pointer;
}
.qrcode_desc_bottom{
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 18px;
    line-height: 24px;
    margin-top: 40px;
    cursor: pointer;
    position: absolute;
    right: 30px;
    bottom:0;
}


.itemImg {
    height: 60px;
    width: 60px;
}

.itemImg img {
    height: 100%;
    width: 100%;
    border-radius: 50%;
}

.itemMain {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    background: #f5f5f5;
    border-radius: 20px;
    padding: 20px;
    box-sizing: border-box;
    cursor: pointer;
}

.itemMess {
    margin-left: 30px;
}

.chanMain {
    height: 500px;
    overflow: auto;
}

.chooseClick {
    border: 1px solid #37DC94;
}

.back_div{
	width: 80px;
	height: 30px;
	background: #4F5E65;
	color: #fff;
	position: absolute;
	bottom: 10px;
	right: 260px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	cursor: pointer;
}
</style>
